package org.come.Jpanel;

import com.tool.btn.FormsOnOffBtn;
import com.tool.btn.PXWspSupportBtn;
import com.tool.btn.SupportBtn;
import com.tool.btn.WspSupportBtn;
import com.tool.tcpimg.UIUtils;
import org.come.until.SrcollPanelUI;

import javax.swing.*;
import java.awt.*;
import java.util.List;



public class PXSupportListJpanel extends JPanel {

	private JScrollPane jScrollPane; // 召唤兽列表滚动条
	private JList<String> listpet;// 召唤兽列表
	private DefaultListModel<String> listModel;// 放置召唤兽的对象
	private PXWspSupportBtn btntop,// 向上图标
			btnbottom,// 向下图标
			btntopset,// 置顶图标
			btnbottomset;// 置底图标
	private JLabel labOpen;
	private JLabel labLocking;
	public JLabel labgundong;
	public PXSupportListJpanel() {
//			 labgundong = new JLabel(new ImageIcon("skin/8100226/button/23.png"));
//			 this.labgundong.setBounds(190, 64, 17, 175);
//				this.add(this.labgundong);
//				this.setPreferredSize(new Dimension(230, 320));
				this.setPreferredSize(new Dimension(293, 409));
				this.setLayout(null);
				this.setBackground(UIUtils.Color_BACK);
			// 关闭按钮事件
			FormsOnOffBtn offBtn = new FormsOnOffBtn("inkImg/old/2/1.png", 1, 620);
			offBtn.setBounds(293 - 37, 10, 25, 25);
			this.add(offBtn);

		
		
		


		listModel = new DefaultListModel<String>();

		// 召唤兽列表
		listpet = new JList<String>() {
			{
				setOpaque(false);
			} // instance initializer
		};
		listpet.setSelectionBackground(new Color(33, 42, 52));
		listpet.setFont(new Font("微软雅黑", 1, 14));
		listpet.setBackground(UIUtils.Color_BACK); // 设置列表框为透明背景
		listpet.setForeground(Color.green);
		listpet.setSelectionForeground(Color.green);
		listpet.setModel(listModel);


		// 召唤兽列表滚动条
		jScrollPane = new JScrollPane(listpet);
		jScrollPane.setVerticalScrollBarPolicy(22);
		jScrollPane.getVerticalScrollBar().setUI(new SrcollPanelUI());
		jScrollPane.getViewport().setOpaque(false);
		jScrollPane.setOpaque(false);
		jScrollPane.setBounds(51, 46, 194, 316);
		jScrollPane.setBorder(BorderFactory.createEmptyBorder());
		jScrollPane.setHorizontalScrollBarPolicy(31);
		this.add(jScrollPane);

			// 向上图标
			btntop = new PXWspSupportBtn("skin/8100226/button/B42.png", 1, 0, this);
			btntop.setBounds(258, 118, 17, 17);
			this.add(btntop);
			// 向下图标
			btnbottom = new PXWspSupportBtn("skin/8100226/button/B43.png", 1, 1, this);
			btnbottom.setBounds(258, 147, 17, 17);
			this.add(btnbottom);
			// 置顶图标
			btntopset = new PXWspSupportBtn("skin/8100226/button/19.png", 1, 2,"顶", this);
			btntopset.setBounds(258, 201, 18, 18);
			this.add(btntopset);
			// 置底图标
			btnbottomset = new PXWspSupportBtn("skin/8100226/button/19.png", 1, 3,"底", this);
			btnbottomset.setBounds(258, 230, 18, 18);
			this.add(btnbottomset);
	}

	private ImageIcon icon;

	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
//		if (icon == null)
				icon = new ImageIcon("inkImg/newbackground/B254.png");
				// 背景
				g.drawImage(icon.getImage(), 0, 0, 293, 409, this);
	}

	// 初始列表
	public void initS(List<String> list) {
		listModel.clear();
		for (int i = 0; i < list.size(); i++) {
			listModel.addElement(list.get(i));
		}
	}

	public DefaultListModel<String> getListModel() {
		return listModel;
	}

	public void setListModel(DefaultListModel<String> listModel) {
		this.listModel = listModel;
	}

	public JList<String> getListpet() {
		return listpet;
	}

	public void setListpet(JList<String> listpet) {
		this.listpet = listpet;
	}

}
